home *** CD-ROM | disk | FTP | other *** search
-
- {EXPAND.PAS is a procedure written for the IBM PC and its compatibles
- in Turbo Pascal for the purpose of expanding data compressed with
- COMPRESS.PAS. It is not a stand-alone program.}
-
- {Fill <count> words of memory starting at <seg:ofs>
- with the 16-bit value <word>}
-
- procedure FillW(seg,ofs,count,word:integer);
- begin
- inline
- ($8B/$86/seg/ {MOV AX,seg}
- $8E/$C0/ {MOV ES,AX}
- $8B/$BE/ofs/ {MOV DI,ofs}
- $8B/$86/word/ {MOV AX,word}
- $8B/$8E/count/ {MOV CX,count}
- $FC/ {CLD}
- $F3/$AB) {REPZ STOSW}
- end;
-
- procedure Expand(srcofs,picsize:integer);
-
- const escapechar = $F800; {binary 1111100000000000}
- transparent = $07FA;
- scrnseg = $B800; {start segment of video RAM}
-
- var srcptr,destptr,data,runlength,i: integer;
-
- begin
- srcptr := 0;
- destptr := 0;
- while srcptr < picsize * 2 do
- begin
- data := MemW[Cseg:srcofs+srcptr]; {fetch next word}
- srcptr := srcptr + 2;
- if (data and escapechar) = escapechar {test top 5 bits}
- then begin {it's a count word}
- runlength := data xor escapechar; {unpack count part}
- data := MemW[Cseg:srcofs+srcptr]; {fetch next word}
- srcptr := srcptr + 2;
- if data = transparent {color is transparent}
- then destptr := destptr + (2 * runlength) {so just bump pointer}
- else begin
- FillW(scrnseg,destptr,runlength,data); {fill screen memory}
- destptr := destptr + (2 * runlength)
- end
- end
- else begin {it's a singleton}
- MemW[scrnseg:destptr] := data;
- destptr := destptr + 2
- end
- end
- end;
-
- e begin